import Vue from 'vue'
import Vuex from 'vuex'
import state from './state'
import actions from './actions'
import mutations from './mutations'
Vue.use(Vuex);

let modules = {};

const requireAllModules = require.context('./modules', true, /\.js$/);

requireAllModules.keys().forEach((key) => {
  let module = requireAllModules(key).default;
  if (module && module.name && module.namespaced) {
    modules[module.name] = module;
  }
});

export default new Vuex.Store({
  state,
  actions,
  mutations,
  modules: modules,
  strict: process.env.NODE_ENV !== 'production',
})
